package com.ct.controller;

import java.util.List;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ct.entity.po.TravelApproval;
import com.ct.entity.query.TravelApprovalQuery;
import com.ct.entity.vo.ResponseVO;
import com.ct.service.TravelApprovalService;

import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotEmpty;

/**
 * 经理视频出差申请记录 Controller
 */
@RestController("travelApprovalController")
@RequestMapping("/travelApproval")
public class TravelApprovalController extends ABaseController {

    @Resource
    private TravelApprovalService travelApprovalService;

    /**
     * 根据条件分页查询
     */
    @RequestMapping("/loadDataList")
    public ResponseVO loadDataList(TravelApprovalQuery query) {
        return getSuccessResponseVO(travelApprovalService.findListByPage(query));
    }

    /**
     * 新增
     */
    @RequestMapping("/add")
    public ResponseVO add(TravelApproval bean) {
        travelApprovalService.add(bean);
        return getSuccessResponseVO(null);
    }

    /**
     * 批量新增
     */
    @RequestMapping("/addBatch")
    public ResponseVO addBatch(@RequestBody List<TravelApproval> listBean) {
        travelApprovalService.addBatch(listBean);
        return getSuccessResponseVO(null);
    }

    /**
     * 批量新增/修改
     */
    @RequestMapping("/addOrUpdateBatch")
    public ResponseVO addOrUpdateBatch(@RequestBody List<TravelApproval> listBean) {
        travelApprovalService.addBatch(listBean);
        return getSuccessResponseVO(null);
    }

    /**
     * 根据TravelApprovalId查询对象
     */
    @RequestMapping("/getTravelApprovalByTravelApprovalId")
    public ResponseVO getTravelApprovalByTravelApprovalId(Integer travelApprovalId) {
        return getSuccessResponseVO(travelApprovalService.getTravelApprovalByTravelApprovalId(travelApprovalId));
    }

    /**
     * 根据TravelApprovalId修改对象
     */
    @RequestMapping("/updateTravelApprovalByTravelApprovalId")
    public ResponseVO updateTravelApprovalByTravelApprovalId(TravelApproval bean, Integer travelApprovalId) {
        travelApprovalService.updateTravelApprovalByTravelApprovalId(bean, travelApprovalId);
        return getSuccessResponseVO(null);
    }

    /**
     * 根据TravelApprovalId删除
     */
    @RequestMapping("/deleteTravelApprovalByTravelApprovalId")
    public ResponseVO deleteTravelApprovalByTravelApprovalId(Integer travelApprovalId) {
        travelApprovalService.deleteTravelApprovalByTravelApprovalId(travelApprovalId);
        return getSuccessResponseVO(null);
    }

    /**
     * 分页查询出差审批记录
     * 
     * @param userId   工号
     * @param pageNo   页码
     * @param pageSize 页大小
     * @return 分页结果
     */
    @RequestMapping("/getApproveTravelRecord")
    public ResponseVO getApproveTravelRecord(@NotEmpty String userId, Integer pageNo, Integer pageSize) {
        return getSuccessResponseVO(travelApprovalService.getApproveTravelRecord(userId, pageNo, pageSize));
    }

    @RequestMapping("/getTravelApprovalByTravelId")
    public ResponseVO getTravelApprovalByTravelId(@RequestParam Integer travelId) {
        return getSuccessResponseVO(travelApprovalService.getTravelApprovalByTravelId(travelId));
    }

}